<?php
/*
 * MiniMe - a minimalistic OStatus complient microblogging tool
 * Copyright (C) 2010, Tuomas Koski - koski.tuomas@gmail.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @author     Tuomas Koski <koski.tuomas@gmail.com>
 * @copyright  Tuomas Koski
 * @license    http://www.gnu.org/licenses/lgpl.txt
 */
abstract class Controller_Abstract {
    
    protected $getParams;
    protected $postParams;
    protected $phpInput;
    
    protected $output;
    protected $headers = array();

    protected $conf;
    
    protected function __construct($getParams, $postParams, $phpInput, $conf) {
        $this->getParams  = $getParams;
        $this->opstParams = $postParams;
        $this->phpInput   = $phpInput;
        $this->conf = $conf;
    }
    
    public function outputHeaders () {
        foreach ($this->headers as $headername => $headervalue) {
            if(is_numeric($headername)) {
                // This is used for HTTP/1.1 204 No Content kind of headers.
                header($headervalue);    
            } else {
                header($headername . ": " . $headervalue);
            }
        }
    }
    
    public function outputBody () {
        echo $this->output;
    }
    
    public function getOutputBody() {
        return $this->output;
    }
    
    public function getHeaders() {
        return $this->headers;
    }
}